#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read() {
    int x=0,f=0,ch=getchar();
    while(!isdigit(ch)) f|=ch=='-',ch=getchar();
    while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
int T;
const int N=2e5+5;
int n,m,L,V;
int d[N];
int v[N];
int a[N];
const int M=1e6+5;
int p[M];
int res=0;
int sum[M];
signed main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--) {
        n=read();
        m=read();
        L=read();
        V=read();
        memset(sum,0,sizeof(sum));
        res=0;
        for(int i=1;i<=n;i++) {
            d[i]=read();
            v[i]=read();
            a[i]=read();
        }
        for(int i=1;i<=m;i++) p[i]=read();
        for(int i=1;i<=m;i++) {
            sum[p[i]]++;
        }
        for(int i=1;i<=L;i++) sum[i]+=sum[i-1];
        for(int i=1;i<=n;i++) {
            long double h=((long double)(1)*V*V-(long double)(1)*v[i]*v[i])/(2.0*a[i]);
            if(a[i]==0) {
                if(v[i]>V&&(sum[L]-sum[d[i]-1]>0||(d[i]==0&&sum[L]))) ++res;
            }
            else if(a[i]>0) {
                if(v[i]>V) {
                    if(sum[L]-sum[d[i]-1])
                    ++res;
                    continue;
                }
                int u;
                int w=V*V-v[i]*v[i];
                int q=2*a[i];
                if(w%q==0) u=d[i]+w/q+1;
                else u=d[i]+w/q+1;
                if(u<=L) {
                    if(sum[L]-sum[u-1]>0) {
                        ++res;
                    }
                }
            }
            else if(a[i]<0) {
                if(v[i]<V) continue;
                int u,v;
                u=d[i];
                v=floor(d[i]+h-0.0000001);
                if(sum[v]-sum[u-1]>0) {
                    ++res;
                }
            }
        }
        cout<<res<<' ';
        if(res==0) {
            cout<<m<<'\n';
        }
        else {
            cout<<m-1<<'\n';
        }
    }
    return 0;
}
